import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.CardLayout;
import javax.swing.JLabel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import java.util.*;


public class TeacherModeGui extends JPanel {

	// auto generated quick fix
	private static final long serialVersionUID = 1L;
	
	private JTextField textFieldClassSelection;
	private JTextField textFieldListName;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TeacherModeGui frame = new TeacherModeGui();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * 
	 * 	
	 * container  - holds gui elements
	 * components - are the gui elements
	 * 
	 * 
	 * Create the frame.
	 * _________________
	 * |			|x|| 	The outline is the frame
	 * |_______________|
	 * |	////////   |	
	 * |	////////   | 	The shaded area is parts of the panel
	 * |	////////   |
	 * __________________
	 * 
	 * CardLayout is going to be a container of containers, so
	 * ContentPane is CardLayout all other panels are GroupLayout.
	 * 
	 * 
	 *
	 */
	public TeacherModeGui() {
		this.setLayout(new CardLayout(0, 0));
		
		JPanel pnlMainMenu = new JPanel();
		this.add(pnlMainMenu, "pnlMainMenu");
		
		JLabel lblTeacherMode = new JLabel("Teacher Mode");
		
		JLabel lblAccessRecords = new JLabel("Access Student Records");
		
		JButton btnStudentRecords = new JButton("Student Records");
		
		JLabel lblManageVocab = new JLabel("Manage Vocabulary");
		
		// Just before the Manage Button was clicked:
		
	
		
		JButton btnManage = new JButton("Manage");
		btnManage.addActionListener(new ActionListener() {
			// When Manage button is clicked -- Change the visible card
			// Teacher Mode Main Menu changes to Manage Vocab Menu
			public void actionPerformed(ActionEvent arg0) {
				Container pnlContent = TeacherModeGui.this;
				CardLayout layout = (CardLayout)(pnlContent.getLayout());
				layout.show(pnlContent, "pnlManageVocab");
			}
		});
		GroupLayout gl_pnlMainMenu = new GroupLayout(pnlMainMenu);
		gl_pnlMainMenu.setHorizontalGroup(
			gl_pnlMainMenu.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlMainMenu.createSequentialGroup()
					.addGroup(gl_pnlMainMenu.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlMainMenu.createSequentialGroup()
							.addGap(152)
							.addComponent(lblTeacherMode, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_pnlMainMenu.createSequentialGroup()
							.addGap(15)
							.addGroup(gl_pnlMainMenu.createParallelGroup(Alignment.LEADING, false)
								.addGroup(gl_pnlMainMenu.createSequentialGroup()
									.addComponent(lblAccessRecords)
									.addGap(78)
									.addComponent(btnStudentRecords))
								.addGroup(gl_pnlMainMenu.createSequentialGroup()
									.addComponent(lblManageVocab)
									.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
									.addComponent(btnManage)
									.addGap(14)))))
					.addContainerGap(80, Short.MAX_VALUE))
		);
		gl_pnlMainMenu.setVerticalGroup(
			gl_pnlMainMenu.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlMainMenu.createSequentialGroup()
					.addGap(15)
					.addComponent(lblTeacherMode, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
					.addGap(32)
					.addGroup(gl_pnlMainMenu.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblAccessRecords)
						.addComponent(btnStudentRecords))
					.addGap(14)
					.addGroup(gl_pnlMainMenu.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblManageVocab)
						.addComponent(btnManage))
					.addContainerGap(110, Short.MAX_VALUE))
		);
		pnlMainMenu.setLayout(gl_pnlMainMenu);
		
		JPanel pnlManageVocab = new JPanel();
		this.add(pnlManageVocab, "pnlManageVocab");
		
		JLabel lblVocabularyManager = new JLabel("Vocabulary Manager");
		
		JLabel lblCreateVocabList = new JLabel("Create a New Vocabulary List");
		
		JLabel lblAddVocab = new JLabel("Add Words to an Existing List");
		
		JLabel lblDisplayList = new JLabel("Display all Vocabulary List");
		
		JButton btnCreateVocabList = new JButton("Create");
		btnCreateVocabList.addActionListener(new ActionListener() {
			// When create button is clicked - Change the card
			// Vocab Manage Menu changes to Create Vocab List Menu 
			public void actionPerformed(ActionEvent arg0) {
				Container pnlContent =TeacherModeGui.this;
				CardLayout layout = (CardLayout)(pnlContent.getLayout());
				layout.show(pnlContent, "pnlCreateVocabList");
			}
		});
		
		JButton btnAddVocab = new JButton("Add Words");
		
		JButton btnDisplayList = new JButton("Display Lists");
		GroupLayout gl_pnlManageVocab = new GroupLayout(pnlManageVocab);
		gl_pnlManageVocab.setHorizontalGroup(
			gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlManageVocab.createSequentialGroup()
					.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlManageVocab.createSequentialGroup()
							.addGap(139)
							.addComponent(lblVocabularyManager))
						.addGroup(gl_pnlManageVocab.createSequentialGroup()
							.addGap(15)
							.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_pnlManageVocab.createSequentialGroup()
									.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
										.addComponent(lblCreateVocabList)
										.addComponent(lblAddVocab))
									.addPreferredGap(ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
									.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
										.addComponent(btnCreateVocabList)
										.addComponent(btnDisplayList)
										.addComponent(btnAddVocab)))
								.addComponent(lblDisplayList))))
					.addContainerGap(83, Short.MAX_VALUE))
		);
		gl_pnlManageVocab.setVerticalGroup(
			gl_pnlManageVocab.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlManageVocab.createSequentialGroup()
					.addGap(15)
					.addComponent(lblVocabularyManager)
					.addGap(58)
					.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_pnlManageVocab.createSequentialGroup()
							.addComponent(lblCreateVocabList)
							.addGap(21))
						.addGroup(gl_pnlManageVocab.createSequentialGroup()
							.addComponent(btnCreateVocabList)
							.addGap(18)))
					.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblAddVocab)
						.addComponent(btnAddVocab))
					.addGap(25)
					.addGroup(gl_pnlManageVocab.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblDisplayList)
						.addComponent(btnDisplayList))
					.addContainerGap(67, Short.MAX_VALUE))
		);
		pnlManageVocab.setLayout(gl_pnlManageVocab);
		
		JPanel pnlDisplayList = new JPanel();
		this.add(pnlDisplayList, "name_1317079531112705000");
		
		JLabel lblDisplayListMenu = new JLabel("Display Vocabulary List Menu");
		
		JComboBox comboBoxClassSelect = new JComboBox();
		
		JLabel lblSelectClass = new JLabel("Select Class:");
		
		JLabel lblSelectList = new JLabel("Select List:");
		
		JComboBox comboBox = new JComboBox();
		
		JLabel lblYourVocabularyList = new JLabel("Your Vocabulary List:");
		
		JLabel lblReturnMainMenu = new JLabel("Return to Main Menu");
		
		JButton btnReturnMainMenu = new JButton("Main Menu");
		
		JScrollPane scrollPaneYourVocabList = new JScrollPane();
		GroupLayout gl_pnlDisplayList = new GroupLayout(pnlDisplayList);
		gl_pnlDisplayList.setHorizontalGroup(
			gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlDisplayList.createSequentialGroup()
					.addGap(117)
					.addComponent(lblDisplayListMenu)
					.addContainerGap(138, Short.MAX_VALUE))
				.addGroup(gl_pnlDisplayList.createSequentialGroup()
					.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlDisplayList.createSequentialGroup()
							.addGap(28)
							.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
								.addComponent(btnReturnMainMenu)
								.addComponent(lblSelectList)
								.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 121, GroupLayout.PREFERRED_SIZE)
								.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.TRAILING)
									.addComponent(comboBoxClassSelect, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE)
									.addComponent(lblReturnMainMenu))))
						.addGroup(gl_pnlDisplayList.createSequentialGroup()
							.addGap(39)
							.addComponent(lblSelectClass)))
					.addPreferredGap(ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
					.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
						.addComponent(lblYourVocabularyList)
						.addComponent(scrollPaneYourVocabList, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE))
					.addGap(19))
		);
		gl_pnlDisplayList.setVerticalGroup(
			gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlDisplayList.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblDisplayListMenu)
					.addGap(18)
					.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblYourVocabularyList)
						.addComponent(lblSelectClass))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_pnlDisplayList.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlDisplayList.createSequentialGroup()
							.addComponent(comboBoxClassSelect, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(12)
							.addComponent(lblSelectList)
							.addGap(18)
							.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(38)
							.addComponent(lblReturnMainMenu)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(btnReturnMainMenu))
						.addComponent(scrollPaneYourVocabList, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(11, Short.MAX_VALUE))
		);
		
		JTextArea textAreaYourVocabList = new JTextArea();
		scrollPaneYourVocabList.setViewportView(textAreaYourVocabList);
		pnlDisplayList.setLayout(gl_pnlDisplayList);
		
		JPanel pnlCreateVocabList = new JPanel();
		this.add(pnlCreateVocabList, "pnlCreateVocabList");
		
		JLabel lblCreateVocabMenu = new JLabel("Create Vocabulary List:");
		
		JLabel lblClassSelection = new JLabel("Name of Class Selection:");
		
		textFieldClassSelection = new JTextField();
		textFieldClassSelection.setColumns(10);
		
		JLabel lblNameOfVocabList = new JLabel("Name of Vocabulary List:");
		
		textFieldListName = new JTextField();
		textFieldListName.setColumns(10);
		
		JButton btnSubmit = new JButton("Submit");
		
		
		JLabel lblPreviousCard = new JLabel("Previous Page:");
		
		JButton btnPrevious = new JButton("Previous");
		
		JScrollPane scrollPane = new JScrollPane();
		GroupLayout gl_pnlCreateVocabList = new GroupLayout(pnlCreateVocabList);
		gl_pnlCreateVocabList.setHorizontalGroup(
			gl_pnlCreateVocabList.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
					.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
							.addGap(22)
							.addComponent(lblCreateVocabMenu))
						.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
							.addGap(28)
							.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
							.addPreferredGap(ComponentPlacement.RELATED, 4, Short.MAX_VALUE)
							.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.TRAILING)
								.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
									.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.TRAILING, false)
											.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
												.addComponent(textFieldClassSelection, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
											.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
												.addComponent(lblClassSelection)
												.addGap(30)))
										.addComponent(lblNameOfVocabList)
										.addComponent(textFieldListName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
									.addGap(59))
								.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
									.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING)
										.addComponent(btnPrevious)
										.addComponent(lblPreviousCard))
									.addGap(22))))
						.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
							.addComponent(btnSubmit)
							.addContainerGap())))
		);
		gl_pnlCreateVocabList.setVerticalGroup(
			gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
					.addGap(20)
					.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblCreateVocabMenu)
						.addComponent(lblClassSelection))
					.addGap(4)
					.addGroup(gl_pnlCreateVocabList.createParallelGroup(Alignment.LEADING, false)
						.addGroup(gl_pnlCreateVocabList.createSequentialGroup()
							.addComponent(textFieldClassSelection, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(23)
							.addComponent(lblNameOfVocabList)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(textFieldListName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(btnSubmit)
							.addGap(4)
							.addComponent(lblPreviousCard)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(btnPrevious)
							.addPreferredGap(ComponentPlacement.RELATED))
						.addComponent(scrollPane))
					.addContainerGap(35, Short.MAX_VALUE))
		);
		
		final JTextArea textArea = new JTextArea();
		textArea.setRows(10);
		textArea.setColumns(12);
		scrollPane.setViewportView(textArea);
		pnlCreateVocabList.setLayout(gl_pnlCreateVocabList);
		
		// When  Submit Button is clicked
		btnSubmit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
		
				// Read the fields in from the gui
				
				String class_name  = textFieldClassSelection.getText();
				
				String list_name   = textFieldListName.getText();
				
				//Use an array list since we want the words to grow
				ArrayList<String> vocab_list = new ArrayList<String>();
				String vocab_words = textArea.getText();
				Scanner sc = new Scanner(vocab_words);
				// iterate over words of the list and them to our vocab list
				while ( sc.hasNext() ) {
					vocab_list.add(sc.next());
				
				// Next store the data
					
					
				// Then redirect the user to Display
					
					
				}
			}
		});
	}
}
